<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="async_submit_test1.aspx.cs" Inherits="jq_form_plug.async_submit_test" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery.ajax异步提交方式</title> <style type="text/css"> td { padding: 5px; } tr td:first-child { text-align: right; } caption { font-weight: bolder; color: red; } form { margin: 20px; } </style> <script src="Script/jquery-1.7.1.js"></script> <script type="text/javascript"> $(document).ready(function () { $("#btnAjaxSubmit").click(function () { var options = { url: 'async_submit_test1.aspx?action=SaveUserInfo', type: 'post', dataType: 'text', data: $("#form1").serialize(), success: function (data) { if (data.length > 0) $("#responseText").text(data); } }; $.ajax(options); return false; }); }); </script></head><body> <form id="form1" method="post"> <table border="1"> <caption>jQuery.ajax异步提交方式</caption> <tr> <td>用户名:</td> <td> <input type="text" name="loginName" /></td> </tr> <tr> <td>性 别:</td> <td> <input type="radio" name="sex" value="0" checked="checked" />男 <input type="radio" name="sex" value="1" />女 </td> </tr> <tr> <td>爱 好:</td> <td> <input type="checkbox" name="cbLoveYy" value="1" />游泳 <input type="checkbox" name="cbLoveYx" value="1" />游戏 <input type="checkbox" name="cbLovePs" value="1" />爬山 </td> </tr> <tr> <td>所属国家:</td> <td> <select name="country"> <option value="请选择" selected="selected">请选择</option> <option value="中国">中国</option> <option value="岛国">岛国</option> </select> </td> </tr> <tr> <td colspan="2" style="text-align: center"> <input id="btnAjaxSubmit" type="submit" value="jQuery.ajax提交" /> </td> </tr> </table> </form> <br /> <label id="responseText"></label></body></html>
评论